home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: MegaDisc / MegaDisc 06 (1988)(MegaDisc Digital Publishing)(AU)[m][WB].zip / MegaDisc 06 (1988)(MegaDisc Digital Publishing)(AU)[m][WB].adf / FEEDBACK / GAMES-INTRO < prev    next >
Text File  |  1988-03-27  |  20KB  |  454 lines

  1.  
  2.  
  3.                 AN AMIGABASIC/C TUTORIAL DISK BY GARY O'CONNOR
  4.  
  5.  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  6.  
  7.          ED. NOTE: Gary sent in a disk full of very useful and informative
  8.          explanations and tutorials and programs illustrating different
  9.          aspects of programming. He has a very clear way of explaining
  10.          complex problems, and anyone interested in programming on the
  11.          Amiga would do well to have a look at it. He's kindly let us send
  12.          it out as a Theme Disk, and may well send more in as a series.
  13.          Below is his INTRO which explains some of the games on his disk.
  14.  
  15.  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  16.  
  17.  
  18.  
  19.  
  20.         This disc contains a game, a demo programme and two Utilities
  21.   that I've  written in AmigaBASIC, that I thought you might find
  22.   interesting.
  23.  
  24.         There is a `C' interpretation of the game to demonstrate the
  25.   difference in programme execution times. The 'C' Code is included for
  26.   your perusal.
  27.  
  28.         They all use SYSTEM 1.2 and will not operate on 1.1 as they employ
  29.   the larger screen sizes available with 1.2.
  30.  
  31.         The game was written as an early exercise in AmigaBASIC.
  32.  
  33.         This disc has all the necessary BITMAPS in the Libs directory but I
  34.   have included six more in the main directory, under icons, which I thought
  35.   you might you might find useful, if you don't already have them. All the
  36.   programmes on this disc assume that you have the necessary BitMaps in your
  37.   libs directory.
  38.  
  39.         Each of the programmes demonstrate the use of `System Sub-Routines'.
  40.   These routines have, generally, been used instead of standard AmigaBASIC
  41.   commands wherever it is possible. You'll find this to be good practice for
  42.   your inevitable conversion to `C', in fact `C' code will no longer look
  43.   nearly as weird as it used to.
  44.  
  45.         On this disc you will find extensive use of; DiskFonts, text
  46.   positioning using `CALL Move&', changing between `JAM1' and `JAM2' modes
  47.   using `CALL SetDrMd&', scrolling using `CALL ScrollRaster&', changeing
  48.   foreground and background colours using `CALL SetAPen&' and SetBPen&'
  49.   along with other `CALL's to the Intuition Library and so on.
  50.  
  51.         I believe that a close investigation of the contents of this disc
  52.   will  answer some of those questions that you, inevitably, ask yourself
  53.   when you are beginning to write programs such as `How do they do that?'
  54.  
  55.         The `Text Demo' programme will explain how you can include text in
  56.   your graphics without wiping out some of your artwork, it will show you
  57.   how  to position your text in your graphics rather than having to build
  58.   your  graphics around your text. It will show you how to make `Shadowed
  59.   Text' and  how to `Fade' text, even how to make text move around the
  60.   screen. It will  demonstrate the wonders of `Scrolling' in a million
  61.   different directions using AmigaBASIC with explanations in English.
  62.  
  63.         The `ASCII.ref' Utility will very neatly tell you what `Code' is
  64.   returned to your programme when you use the `INKEY$' function, at the
  65.   same  time displaying the `On Screen' representation of that, returned,
  66.   value. It  also demonstrates the use of `Disk Fonts' and `MENU's,
  67.   allowing you, via the  `MENU' function to choose any of the various Fonts
  68.   contained on your disc.
  69.  
  70.         It is possible to write a routine to search your disk for the
  71.   available  fonts and then place them in your `MENU' selection. This has
  72.   been the method  used for this Utility and that makes it reasonably
  73.   `Transportable'  (meaning you can just copy the programme to any disc and
  74.   it will return the  available Fonts. Provided you have the necessary
  75.   BitMaps in the libs directory of that disc).
  76.  
  77.  
  78.   ****************************************************************************
  79.  
  80.  
  81.      CAUTION FOR ASCII.ref PROGRAMME:::::::
  82.  
  83.         This programme loads all the available fonts into memory and can
  84.   therefore be `memory intensive'. This disc has twenty eight disc based
  85.   fonts  and two resident fonts. That is the maximum a 512k AMIGA seems to
  86.   handle and  still run the programme. You WILL need more memory if you
  87.   have more fonts.
  88.   THE ONLY WAY IT WILL RUN ON THIS DISC is if you drag it's ICON out of the
  89.   disc window and close it (the disc window on the workbench) before you
  90.   attempt to run it.
  91.  
  92.         That would not be necessary on a standard disc, as it has less fonts.
  93.  
  94.  
  95.   *****************************************************************************
  96.  
  97.  
  98.         You will find complete descriptions of each programme listed below.
  99.   I  hope you can get something out of it. I offer it all freely in the
  100.   hope of  promoting an interest in programming and to answer some of those
  101.   nagging, generally unanswerable, questions.
  102.  
  103.         CAUTION::::
  104.         Some of these programs use the Font called `pcfont'. It is not a
  105.   standard Font, so, if you wish to use these programs on other discs, you
  106.   will have to do one of two things....
  107.  
  108.         1. Change the programs so that they call the standard `topazfont'
  109.  
  110.         or
  111.  
  112.         2. Copy the pcfont from this disc to the one you will be using.
  113.            To do that, follow these instructions .....
  114.  
  115.            If you have two disc drives put this disc in df0: and `YOUR DISC'
  116.            in df1:. Boot with this disc and enter the cli from it, then type
  117.  
  118.            MAKEDIR df1:libs/pcfont
  119.            COPY df0:libs/pcfont to df1:libs/pcfont all
  120.            COPY df0:libs/pcfont.font to df1:libs/pcfont.font
  121.  
  122.            If you have one Disc Drive, Boot with this disc and enter the
  123.            cli.
  124.            Then type
  125.  
  126.            EXECUTE quickram
  127.  
  128.            Wait till the "ALL DONE NOW" appears, then continue typing the
  129.            following
  130.  
  131.            MAKEDIR ram:pcfont
  132.            COPY df0:libs/pcfont to ram:pcfont all
  133.            COPY df0:libs/pcfont.font to ram:
  134.  
  135.            Now put `YOUR DISC' in df0: and type
  136.  
  137.            MAKEDIR df0:libs/pcfont
  138.            COPY ram:pcfont to df0:libs/pcfont all
  139.            COPY ram:pcfont.font to df0:libs
  140.  
  141.         Quickram is an `executeable' batch file, in the `S' directory on
  142.   this  disc, that creates a `ram disc' with a `C' directory and assigns
  143.   all calls  to `C' to the ram:c. This has the effect of reducing disk
  144.   swapping to a minimum.
  145.  
  146.         There are two other associated `batch files' in the `S' directory.
  147.   One is called `RAMIT' the other is called `CLEARIT'.
  148.  
  149.         RAMIT will copy the action of QUICKRAM but puts the entire `C'
  150.   directory into ram:. CLEARIT clears the ramdisc of its `C' directory and
  151.   re-assigns `C' to SYS:C, returning everything to normality. To use
  152.   CLEARIT,  assuming you have been using QUICKRAM or RAMIT and you are
  153.   still in the CLI, type the following.....
  154.  
  155.            SYS:c/execute CLEARIT
  156.  
  157.         Your CLI will now act normally and QUICKRAM/RAMIT will have been
  158.   removed from the ram: disc.
  159.  
  160.  
  161.   *****************************************************************************
  162.  
  163.  
  164.  
  165.                                  Text Demo
  166.     (Requires Sys 1.2,`graphics',`diskfont' and `intuition' bmaps and
  167.   `pcfont')
  168.  
  169.  
  170.         I wrote Text Demo whilst I was teaching my kids how to use the
  171.   System  Librarys for the purpose of  better placement of text in Graphics
  172.   programmes. It, sort of, evolved as we were going along.
  173.  
  174.         I have since found that everyone who watches it is intrigued and,
  175.   that  those interested in programming, find it informative. Amigans into,
  176.   or only  capable of, AmigaBASIC rush off to adjust their programmes with
  177.   new Title  Pages or to make that text fit into their graphics, rather
  178.   than build their  graphics around the limitations of the `LOCATE' command
  179.   and the JAM2 Mode.
  180.  
  181.         When I get a programme from one of my fellow `Computerists' I now
  182.   see  scrolling screens and fading text, text coming from all directions
  183.   and all of it perfectly placed within their graphics.
  184.  
  185.         I make no pretence to having written the `Perfect Text Demo', it's
  186.   far  from that, but it is, at least, inspirational and gives BASIC
  187.   programmers  a feeling of accomplishment that's hard to explain to
  188.   someone who programmes  in `C' or `68000 Machine Language'. It also
  189.   begins to give anyone who uses  the routines contained in the Librarys,
  190.   an understanding of `C' programming  which will stand them in good stead
  191.   when they finally convert.
  192.  
  193.  
  194.  
  195.  
  196.  
  197.   *****************************************************************************
  198.  
  199.  
  200.  
  201.                                 ASCII.ref
  202.              (Requires Sys 1.2,`graphics.bmap' and `diskfont.bmap')
  203.  
  204.         This UTILITY programme was designed to display, on screen, the ASCII
  205.   value of any key pressed. At least that's how it started out.
  206.  
  207.         I, accidentally, discovered that there was a difference in the
  208.   `graphic' output between `PC.font' and `TOPAZ.font' for the functional
  209.   keys,  (Run the programme and press the `DEL' key or the cursor keys for
  210.   each of  these fonts and you will see what I mean) so the programme grew
  211.   to become a  UTILITY to, not only give you the ASCII value of each key
  212.   pressed, but to display its `character output' as well.
  213.  
  214.         This programme is also a good example of setting a number of `Fonts'
  215.   in memory utilising simple calls that change them instantly.
  216.  
  217.  
  218.                          ****  CAUTION  ****
  219.  
  220.   THIS PROGRAMME WILL NOT RUN ON THIS DISC UNLESS YOU FIRST DRAG IT'S ICON
  221.   OUT  OF THE DISC'S WINDOW AND THEN CLOSE IT (THE DISC'S WINDOW) BEFORE
  222.   ATTEMPTING  TO RUN IT. IF YOU MOVE THE PROGRAMME TO ANOTHER DISC PLEASE
  223.   ENSURE THAT THE  GRAPHICS AND DISKFONT BITMAPS ARE IN THAT DISC'S LIB
  224.   DIRECTORY, AND THAT  pc.font(DIR) AND pc.font.font ARE IN THE FONTS
  225.   DIRECTORY.
  226.   THE EASIEST WAY TO DO THAT IS TO COPY ALL THE BMAPS FROM THE LIBS
  227.   DIRECTORY  ON THIS DISC TO YOUR NEW DISC, ALONG WITH THE ABOVE FONTS TO
  228.   IT'S FONT DIRECTORY. TO DO THAT, USE THE SYSTEM DESCRIBED ABOVE.
  229.  
  230.  
  231.   *****************************************************************************
  232.  
  233.  
  234.  
  235.                                ChangePointer
  236.         (Requires Sys1.2,intuition.bmap,graphics.bmap and the icon.bmap)
  237.  
  238.         Have you ever sat down with a bit of graph paper, sorted out
  239.   a piece  that is 16 sections wide by 15 sections deep, then filled in
  240.   these sections  to draw what will become the new design for your MOUSE
  241.   Pointer? Once you have done that you then have to work out the binary
  242.   representations of what  you've drawn into two separate numbers, both
  243.   covering the entire sixteen  sections but representing four different
  244.   colours(Three colours and  invisible). These numbers are worked out by
  245.   including one colour in both numbers, one colour in the left number and
  246.   the other in the right number. Once you've done that you only have to do
  247.   it 14 (thats FOURTEEN) more times  and then convert all those numbers to
  248.   HEX. Then all thats left to do is work  out how to programme it so that
  249.   it will actually change your Pointer.
  250.  
  251.         Easy!!
  252.  
  253.         Garbage it's easy.
  254.  
  255.         It's a mongrel job.
  256.  
  257.         But imagine how good your programme could look with that special
  258.   pointer for a particular job. Let's say you wanted someone to draw a line
  259.   with the pointer and you could redesign it to be a pencil from within
  260.   your  programme, or you wanted them to push a button so you redesign your
  261.   pointer to be a hand with an outstretched finger.
  262.  
  263.         Well I had such an occasion, so I sat down with a piece of graph
  264.   paper  and I sorted out a section that was 16 sections wide and fifteen
  265.   sections deep and I........................
  266.  
  267.         You get the picture.
  268.  
  269.         Then I thought,
  270.  
  271.         `Here I am with this marvelous piece of machinery and I'm doing all
  272.   this manual work. I must be crazy. Surely my Amiga can do it for me?'
  273.  
  274.         So I developed `ChangePointer'(it's a catchy name isn't it).
  275.  
  276.         I had some problems. Firstly, the computer will give me a STRING
  277.   representation of a HEX number by converting with HEX$(), but I can find
  278.   no  way of obtaining a HEX Number that is not a STRING. This explains all
  279.   the disc access while the programme is running because I had to create a
  280.   Sequential File and then READ it to convert the STRING'ed HEX numbers to
  281.   plain HEX Numbers. I may have been able to `POKE' strings as DATA instead
  282.   of numbers but I'm not too sure that would work.
  283.  
  284.         Secondly, it seems that the Intuition Library is not too thrilled
  285.   with  Basic fooling around with the pointer and, although I've had no
  286.   problems  with any programmes I,ve changed the pointer in, but this
  287.   programme sometimes bogs down. I can only assume it's this area that's
  288.   causing the  problem because the programme seems to be very well behaved
  289.   in all other areas.
  290.  
  291.         When you first startup, you will be presented with a graph
  292.   thats, you guessed it, 16 sections wide and 15 sections deep. Underneath
  293.   that is a colour bar containing four colours that are the same colours
  294.   that  your pointer will be. Beneath that are your `Command' boxes.
  295.  
  296.         The pointer will at first disappear and, when it reappears, it will
  297.   be white. You can now use the pointer, with the left MOUSE button to fill
  298.   in  the squares, choosing the colours from the colour bar. As you choose
  299.   a new colour, the pointer will change to that colour.
  300.  
  301.         Once you have finished your creation and have selected `SAVE', the
  302.   pointer will change to `WAIT' and your DATA will be printed on the left
  303.   section of the screen. You will then be asked to `Select your Hot Spot'.
  304.   That's the position which is the active part when you `click' the MOUSE.
  305.  
  306.         Now you will be asked to name your DATA file, to which the programme
  307.   will append `.DPtr'.
  308.  
  309.         You will then be given the choice of either a `DATA' or a `PROG'
  310.   file.
  311.         A `DATA' file is just that. The file will contain your DATA
  312.   statements and the `OffSet' positions for your Hot Spot.
  313.  
  314.         A `PROG' file is an entire programme that contains all the necessary
  315.   commands to  change your pointer and, if you run it (by CLICKing on the
  316.   DISPLAY box), it will make its own screen, across which it will put seven
  317.   bands of colour and display YOUR pointer. This gives you the opportunity
  318.   to see how YOUR pointer looks over different colours.
  319.  
  320.         If you do `DISPLAY' your pointer, the programme passes control to
  321.   that programme and `ChangePointer'(catchy) is no longer in memory.
  322.  
  323.         Now, whether you create a `DATA' file or a `PROG' file, the pointer
  324.   will change to the one you designed anyway. It does this by creating it's
  325.   own `DATA' file, called `Display1.Ptr' or `Display2.Ptr' etc (up to 6),
  326.   reading it by MERGEing it to this programme. It then puts the name of your
  327.   pointer into one of the six boxes on the left of the screen.
  328.  
  329.         You can call any of the pointers you create (up to six at a time),
  330.   simply by clicking on it's box.
  331.  
  332.         To use the pointer you create, in one of your own programmes, you
  333.   will have to do one of two things.
  334.  
  335.         1. Begin by creating a `PROG' file and `DISPLAY'ing it. This will
  336.   give you all the necessary code you will need to change the pointer, so
  337.   you can  use it as the basis for your programme, or copy the bits you
  338.   need into your programme.
  339.  
  340.         2. Create a `DATA' file and, when you load your programme, MERGE
  341.   your  `DATA' file on to the end. You will have to remove some comments
  342.   that are  also on the file and reference your OffSets to your `Change'
  343.   routine.
  344.  
  345.         In all probability, you will need to load at least one `PROG' file
  346.   to  obtain the code you will need. You will find that it is heavily
  347.   commented. All these comments can be deleted.
  348.  
  349.         If you intend to use more than one POINTER in your programme, it
  350.   would  probably be interesting to LIST `ChangePointer' (I like it), and
  351.   see just what I've done in there.
  352.  
  353.         One word of warning. These files are not initially saved as
  354.   PROGRAMME  files so you cannot start them by clicking on the icons. You
  355.   will have to  either MERGE them to the end of a `loaded' Basic programme
  356.   or Open Basic and  type `load "MyProgramme.DPtr"(Where MyProgramme is the
  357.   name you gave it).  Once it is loaded simply `SAVE' it and then the ICON
  358.   will work.
  359.  
  360.         The reason that each file is appended with either `.DPtr' or `.Ptr'
  361.   is  one of convenience.
  362.  
  363.         Once you have finished working with the files, or you simply no
  364.   longer  require them, you can use the pattern matching ability of the CLI
  365.   to delete all these files in one go.
  366.  
  367.         To DELETE just the `Display1.Ptr' files enter the CLI and type...
  368.  
  369.         DELETE #?.Ptr
  370.  
  371.         You can remove just `YOUR' files by typing
  372.  
  373.         DELETE #?.DPtr
  374.  
  375.         Or you can remove the lot by typing
  376.  
  377.         DELETE #?Ptr
  378.  
  379.         I have not finished with this programme, in fact it is only two days
  380.   old at the time of writing. I have quite a few improvements in mind, and
  381.   some obvious bugs to elliminate.
  382.  
  383.         When I have totally revised it, I will resubmit it along with a
  384.   version written in `C'.
  385.  
  386.         One CAUTION: Take it easy whilst the pointer is actually changeing.
  387.   It seems that this is when the problem mentioned above occurs.
  388.  
  389.   Have fun...
  390.  
  391.  
  392.  
  393.   *****************************************************************************
  394.  
  395.  
  396.                                 THOUGHT-POWER
  397.  
  398.                 (requires Sys 1.2, graphics.bmap & diskfont.bmap)
  399.  
  400.         Thought Power is a game similar to Master Mind that I have written
  401.   for the Amiga.
  402.  
  403.         It uses colours, rather than numbers, but the principle is the
  404.   same.  The Computer chooses four colours, at random, from a palette of
  405.   eight, and  you have to guess, through a series of elliminations, which
  406.   colours they are and which order the Computer has them in.
  407.  
  408.         The game is very easy to follow. You use the MOUSE to choose your
  409.   colours and the Computer fills in the squares. Once you have filled four
  410.   squares you have had one go. The Computer then tells you how many colours
  411.   you got right, and in the right place, and how many colours you got right
  412.   but in the wrong place. At the end of each row of four squares are four
  413.   little squares. The ones filled in white indicate right colours in the
  414.   right  place and the ones filled in purple indicate right colours in the
  415.   wrong
  416.   place. If there are any blanks, then there are that many colours, in your
  417.   selections, that are alltogether wrong.
  418.  
  419.         The position of the white and purple squares is not relative to
  420.   the positions of your colours. They simply tell you how you went. You have
  421.   to work out which ones are the right ones.
  422.  
  423.         The Programme uses the `Menu' function to allow you the choice of
  424.   using just the white indicators. This makes the game a little harder but
  425.   still possible.
  426.  
  427.         As the programme is `memory intensive', a CLEAR statement is
  428.   required  prior to each replay. This caused a few headaches, with the
  429.   `Best go so far'  and the `Menu Choice' features, as each time the CLEAR
  430.   statement is invoked, all variables are reset.
  431.  
  432.         The way I got around this problem was to `PSET' two points on the
  433.   screen and, subsequent to the CLEAR command, read those points with the
  434.   POINT (x,y) function to reset the variables.
  435.  
  436.         I did not include any sounds as I'm only capable of fairly simple
  437.   beeps and twitters. I'm not sure that it needs any but over to you. Feel
  438.   free to change whatever you like. If you come up with any improvements
  439.   let me know.
  440.  
  441.  
  442.  
  443.  
  444.   ************************************************************************
  445.  
  446.         I hope you have some fun with the programmes.
  447.  
  448.         Gary O'Connor
  449.         Penrith.
  450.  
  451.  
  452.   ~~~~~~~~~~~~~~~~~~~~~~~~~~ END OF GAMES-INTRO ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  453.  
  454.